package com.shenmazong.servereduschool.controller;

import com.github.pagehelper.PageInfo;

import com.shenmazong.servereduschool.mapper.TbMajorMapper;
import com.shenmazong.servereduschool.pojo.TbCollage;
import com.shenmazong.servereduschool.pojo.TbMajor;
import com.shenmazong.servereduschool.pojo.TbStage;
import com.shenmazong.servereduschool.service.TbMajorService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ListParamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 专业
 * kxt
 */
@RestController
@RequestMapping("/major")
public class MajorController {
    @Autowired
    TbMajorService tbMajorService;

    /**
     * 专业列表
     * @return
     */
    @PostMapping("/majorList")
    public ResultResponse findMajorList(@RequestBody ListParamVo listParamVo){
        Integer current = listParamVo.getCurrent();
        Integer size = listParamVo.getSize();
        Object tbmajor = listParamVo.getParamMap().get("tbmajor");
        PageInfo pageInfo=tbMajorService.findMajorList(current,size,tbmajor);
        return ResultResponse.SUCCESS(pageInfo);
    }

    /**
     * 专业添加
     * @param tbMajor
     * @return
     */
    @PostMapping("/save")
    public ResultResponse save(@RequestBody TbMajor tbMajor){
        return tbMajorService.add(tbMajor);
    }

    /**
     * 专业回显
     * @return
     */
    @PostMapping("/queryByMajorId")
    public ResultResponse queryByMajorId(@RequestBody TbMajor tbMajor){
        return tbMajorService.queryByMajorId(tbMajor);
    }

    /**
     * 专业修改
     * @param tbMajor
     * @return
     */
    @PostMapping("/updateTbMajor")
    public ResultResponse updateTbMajor(@RequestBody TbMajor tbMajor){
        return tbMajorService.updateTbMajor(tbMajor);
    }

    /**
     * 专业删除
     * @param tbMajor
     * @return
     */
    @PostMapping("/delByMajorId")
    public ResultResponse delByMajorId(@RequestBody TbMajor tbMajor){
        return tbMajorService.delByMajorId(tbMajor);
    }

    /**
     * 专业批量删除
     * @param ids
     * @return
     */
    @PostMapping("/delAll")
    public ResultResponse delAll(@RequestBody List<TbMajor> ids){
        return tbMajorService.delAll(ids);
    }

    /**
     * 列表
     */
    @PostMapping("/findMajor")
    public ResultResponse findMajor(){
        return tbMajorService.findMajor();
    }
}
